<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@page import="com.lmpop.frame.util.Config"%>
<%@page import="java.io.*"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.SimpleDateFormat"%>
<%@ page import=" com.lmpop.frame.util.*"%>

<%
	request.setCharacterEncoding("UTF-8");
	String file_path = "";
	String file_path_tem = "";
	if (request.getParameter("file_path") != null
			&& !request.getParameter("file_path").equals("/")) {
		file_path_tem = file_path;
		file_path = request.getParameter("file_path");
	}
	Config configFile = new Config();
	configFile.init();
	String rootpath = configFile.getString("rootpath");
	String tempDir = rootpath + "templets/html" + file_path + "/";
%>
<html>
	<head>
		<title>在线选择模板</title>
		<link href="/program/admin/index/css/style.css" rel="stylesheet"
			type="text/css">
 <link href="/program/admin/index/css/thickbox.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="/js/jquery.js"></script>
	<script type="text/javascript" src="/js/thickbox.js"></script>
		<script type="text/javascript" src="/js/commen.js"></script>
		<script type="text/javascript" src="channelindex.js"></script>
	
	</head>

	<body>
		<table width="100%" cellpadding="0" cellspacing="0" border="0">
			<tr>
				<td width="90%">
					<h1>
						在线选择模板
					</h1>
				</td>
			</tr>
		</table>
		<form action="submit.jsp" name="index2Form" id="index2Form"
			method="post" target="_self">
			<table width="100%" cellpadding="1" cellspacing="1" border="0"
				class="listtab">
				<tr>
					<td>
						<%
							if (!file_path.equals("/")) {
						%>
						<img width="16" height="16" src="/program/admin/images/dir2.gif">
						<a
							href="/program/admin/updateHtml/alter_index.jsp?file_path=<%=file_path_tem%>">上级目录</a>
						<%
							}
						%>
					</td>
					<td colspan="3">
						当前目录：
						<%=file_path%>
					</td>
				</tr>

				<tr>
					<th width="35%">
						文件名称
					</th>
					<th width="20%">
						文件大小
					</th>
				<th width="35%">
						编辑时间
					</th>
				</tr>
				<%
						File[] filelist=FileUtil.sortComparator(tempDir);
					if (filelist != null && filelist.length > 0) {
						for (int i = 0; i < filelist.length; i++) {
							String file_path_mo = file_path + "/" + filelist[i].getName();
							String file_view_path = "/templets/html/" + file_path_mo;
							String templateDir = rootpath + "templets/html/"+ file_path_mo;
							File file_o = new File(templateDir);
							Date filedate = new Date();
							filedate.setTime(file_o.lastModified());
							//格式化输出时间
							SimpleDateFormat formate = new SimpleDateFormat(
									"yyyy-MM-dd HH:mm:ss");
							String filedateformated = formate.format(filedate);
							String filesize = file_o.length() / 1024 + 1 + " KB";
							boolean isdirectory = file_o.isDirectory();
							String file_reg = "(?i).+?\\.(jpg|gif|jpeg|png|bmp|html|js|css)";
							String file_ending = "";
							int file_end_num = file_path_mo.lastIndexOf(".");
							int file_length = file_path_mo.length();
							if (isdirectory) {
								file_ending = "directory";
							} else {
								file_ending = "other";
							}
				%>

				<tr>
				<td width="10%">
						<%
							if (isdirectory) {
						%>
						<a href="/program/admin/updateHtml/alter_index.jsp?file_path=<%=file_path_mo%>">
						<img src="/program/admin/images/<%=file_ending%>.gif" /><%=filelist[i].getName()%> <%
 	} else {
 %>

					<a href="#" onclick="setIndexTemp('<%=file_path + '/'+filelist[i].getName()%>')"><img src="/program/admin/images/<%=file_ending%>.gif" /><%=filelist[i].getName()%> </a>
							<%
 	}
 %>
						
					</td>
					<td><%=filesize%></td>
					<td><%=filedateformated%></td>
				</tr>
				<%
					}
					}
				%>

			</table>

		</form>
	</body>

</html>
